{include file="/sum/common/script" /}

<style>
    .activity-tag {
        padding: 3px 8px;
        border-radius: 10px;
        line-height: 14px;
        font-size: 12px;
        font-weight: 400;
        margin-right: 8px;
        cursor: pointer;
    }

    .activity-tag:last-of-type {
        margin-right: 0;
    }

    .activity-tag.groupon,
    .activity-tag.groupon_ladder {
        color: var(--el-color-primary);
        background: var(--t-bg-active);
    }

    .goods-index .goods-item .goods-image {
        margin-right: 12px;
    }

    .goods-index .goods-item .goods-title {
        height: 20px;
        line-height: 20px;
        font-size: 14px;
        font-weight: 500;
        color: var(--sa-font);
    }

    .goods-index .goods-item .goods-subtitle {
        height: 16px;
        line-height: 16px;
        font-size: 12px;
        font-weight: 400;
        color: var(--sa-subfont);
        margin-bottom: 6px;
    }
</style>

<div id="index" class="goods-index panel panel-default panel-intro" v-cloak>
    <el-container class="panel-block">
        <el-header class="sa-header">
            <el-tabs class="sa-tabs" v-model="state.filter.data.lang" @tab-change="onChangeTab">
                <el-tab-pane v-for="item in type.data.lang" :key="item" :label="item.name" :name="item.type">
                </el-tab-pane>
            </el-tabs>

            <div class="sa-title sa-flex sa-row-between">
                <div class="sa-title-left">
                    <div class="left-name">短剧管理</div>
                    <sa-filter-condition v-model="state.filter" @filter-delete="onChangeFilter">
                    </sa-filter-condition>
                </div>
                <div class="sa-title-right">
                    <el-button class="sa-button-refresh" icon="RefreshRight" @click="getData"></el-button>
                    <el-button class="sa-button-refresh" icon="Search" @click="onOpenFilter"></el-button>

                    <el-button icon="Download" @click="onDownload">下载剧集模板</el-button>
                    <el-button icon="Upload" type="warning" @click="onImport">批量导入剧集</el-button>

                    {if $auth->check('sum/video/video/add')}
                    <el-button icon="Plus" type="primary" @click="onAdd">新增短剧</el-button>
                    {/if}
                </div>
            </div>
        </el-header>
        <el-main class="sa-main">
            <el-table height="100%" class="sa-table" :data="state.data" stripe @selection-change="onChangeSelection"
                @sort-change="onChangeSort">
                <el-table-column type="selection" width="48" align="center"></el-table-column>
                <el-table-column prop="id" label="ID" min-width="90" sortable="custom"> </el-table-column>
                <el-table-column label="短剧" min-width="320">
                    <template #default="scope">
                        <div class="goods-item sa-flex sa-col-top">
                            <sa-image class="goods-image" :url="scope.row.image" size="64"></sa-image>
                            <div class="right">
                                <div class="goods-title sa-table-line-1">{{scope.row.title}}</div>
                                <div class="goods-subtitle sa-table-line-1">{{scope.row.description}}</div>
                                <el-scrollbar>
                                    <div class="sa-flex">
                                        <template v-for="category in scope.row.category">
                                            <div class="activity-tag groupon">
                                                {{category.name}}
                                            </div>
                                        </template>
                                    </div>
                                </el-scrollbar>
                            </div>
                        </div>
                    </template>
                </el-table-column>

                <el-table-column label="语言" min-width="100">
                    <template #default="scope">
                        <el-tag type="primary">
                            {{ scope.row.lang_text }}
                        </el-tag>
                    </template>
                </el-table-column>

                <el-table-column label="整剧价格" min-width="160" sortable="custom">
                    <template #default="scope">
                        <div class="sa-table-line-1">
                            {{ scope.row.price || '-' }}
                        </div>
                    </template>
                </el-table-column>

                <el-table-column label="总集数" min-width="100" sortable="custom">
                    <template #default="scope">
                        <div class="sa-table-line-1">
                            {{ scope.row.episodes_num || '-' }}
                        </div>
                    </template>
                </el-table-column>

                <el-table-column label="评分" min-width="100" sortable="custom">
                    <template #default="scope">
                        <div class="sa-table-line-1">
                            {{ scope.row.rating || '-' }}
                        </div>
                    </template>
                </el-table-column>


                <el-table-column label="状态" min-width="100">
                    <template #default="scope">
                        <el-tag :type="scope.row.status == 'up' ? 'success' : 'info'">
                            {{ scope.row.status_text }}
                        </el-tag>
                    </template>
                </el-table-column>

                <el-table-column label="权重" min-width="100" sortable="custom">
                    <template #default="scope">
                        <div class="sa-table-line-1">
                            {{ scope.row.weigh || '-' }}
                        </div>
                    </template>
                </el-table-column>

                <el-table-column label="创建时间" width="172">
                    <template #default="scope">
                        {{ scope.row.createtime || '-' }}
                    </template>
                </el-table-column>
                <el-table-column label="更新时间" width="172">
                    <template #default="scope">
                        {{ scope.row.updatetime || '-' }}
                    </template>
                </el-table-column>
                <el-table-column fixed="right" label="操作" min-width="180">
                    <template #default="scope">
                        {if $auth->check('sum/video/episodes')}
                        <el-button type="success" link @click="onEpisodes(scope.row.id)">剧集管理</el-button>
                        {/if}

                        {if $auth->check('sum/video/video/edit')}
                        <el-button type="primary" link @click="onEdit(scope.row.id)">编辑</el-button>
                        {/if}
                        <el-popconfirm width="fit-content" confirm-button-text="确认" cancel-button-text="取消"
                            title="确认删除这条记录?" @confirm="onDelete(scope.row.id)">
                            <template #reference>
                                {if $auth->check('sum/video/video/delete')}
                                <el-button type="danger" link>删除</el-button>
                                {/if}
                            </template>
                        </el-popconfirm>
                    </template>
                </el-table-column>
            </el-table>
        </el-main>
        <el-footer class="sa-footer sa-flex sa-row-between sa-flex-wrap">
            <div class="sa-batch sa-flex">
                <div class="tip">
                    已选择 <span>{{batchHandle.data.length}}</span> 项</div>
                <div class="sa-flex">
                    {if $auth->check('sum/video/video/delete')}
                    <el-button type="danger" :disabled="!batchHandle.data.length" @click="onBatchHandle('delete')">删除
                    </el-button>
                    {/if}
                    {if $auth->check('sum/video/video/edit')}
                    <el-button type="success" :disabled="!batchHandle.data.length" @click="onBatchHandle('up')">上架
                    </el-button>
                    {/if}
                    {if $auth->check('sum/video/video/edit')}
                    <el-button type="info" :disabled="!batchHandle.data.length" @click="onBatchHandle('down')">下架
                    </el-button>
                    {/if}
                </div>
            </div>
            <sa-pagination v-model="pagination" @pagination-change="getData"></sa-pagination>
        </el-footer>
    </el-container>
    <sa-filter v-model="state.filter" @filter-change="onChangeFilter"></sa-filter>
</div>